package com.woniu.microworkorderserver.workadminmag.service.impl;

import com.woniu.microcommonsserver.entity.WorkListInfoEntity;
import com.woniu.microworkorderserver.workadminmag.mapper.WorDispatchMapper;
import com.woniu.microworkorderserver.workadminmag.service.WorDispatchService;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;


/**
*工单调度页面数据
 * */

@Transactional(readOnly = true)
@Service
public class WorDispatchImpl implements WorDispatchService {

    @Resource
    private WorDispatchMapper worDispatchMapper;


    //工单调度页面下，子页面根据传的status来显示的表格个的数据
    @Override
    public List<WorkListInfoEntity> findAll(String status) {

        return worDispatchMapper.findAll(status);
    }

    //工单调度下子页面的已接单页面中--退单的按钮所在的功能点
    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    @Override
    public int updateFishedAccept(int id) {
        worDispatchMapper.updateFishedAccept(id);

        return  1;
    }


    //工单调度下子页面中的 待审工单页面的----通过按钮
    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    @Override
    public int allowWork(int id) {

        worDispatchMapper.allowWork(id);

        return 1;
    }

    //工单调度下子页面中的 待审工单页面的----驳回按钮
    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    @Override
    public int rejectWork(int id) {

        worDispatchMapper.rejectWork(id);

        return 1;
    }

    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    @Override
    public int insertRepair(WorkListInfoEntity workListInfoEntity) {

        worDispatchMapper.insertRepair(workListInfoEntity);

        return 0;
    }

    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    @Override
    public int saveInsert(WorkListInfoEntity workListInfoEntity) {

        worDispatchMapper.saveInsert(workListInfoEntity);

        return 0;
    }

    @Transactional(isolation = Isolation.REPEATABLE_READ,rollbackFor = Exception.class)
    @Override
    public int stopingById(int id) {

        worDispatchMapper.stopingById(id);

        return 0;
    }


}
